/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ChatSystem;

import ChateoController.*;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Scanner;
/**
 *
 * @author adrian
 * @author olga
 */
public class ChatSystem {
    
    public static void main(String[] args) throws Exception {
        boolean GUI=false;
        //With GUI
        if (GUI){
            
        }
        //Without GUI
        else{
            try{
                Scanner sc = new Scanner(System.in);
                System.out.println("Entrez votre login");
                String str = sc.nextLine();
                System.out.println("Bienvenue " + str);
                System.out.println("Veuillez maintenant entrer le port du serveur");
                int port =  Integer.parseInt(sc.nextLine());
                Controller controller = new Controller(str, port);
                controller.connect();
                while(true){
                System.out.println("Enter 1 to send a message, enter something else to disconnect");
                String choice = sc.nextLine();
                if (choice.equals("1")){
                    System.out.println("This is the list of connected users " + controller.getUserList());
                    System.out.println("Enter the login of your friend");
                    String Dest = sc.nextLine();
                    System.out.println("Enter your message");
                    String Mensaje = sc.nextLine();
                    System.out.println("Enter 1 to send a private message, enter something else to send a broadcast message");
                    String publico = sc.nextLine();
                    if (publico.equals("1")){
//                        controller.mensajesBasicos(Mensaje, Dest, true);
                    }
                    else{
 //                       controller.mensajesBasicos(Mensaje, Dest, false);
                    }
                    
                }
                else{
                    controller.disconnect();
                }
                }
                /*Thread.sleep(15000);
                if (controller.DebugMode()){
                System.out.println("Début de la phase de deconnexion");
                }
   
                
                
                controller.disconnect();*/
            }
            catch(NumberFormatException nfe){
                System.out.println("NFE");
                
            } catch (NullPointerException npe) {
                System.out.println("NPE");
            } catch (SocketException se) {
                System.out.println("SE");
            } catch (UnknownHostException uhe) {
                System.out.println("UHE");
            }
            catch (Exception uhe)
            {
                System.out.println("ICH BIN SCHNAPPI");
            }
            
            
        }
        
        
        
    }
    
}
